﻿#region Using Directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#endregion

namespace Nihongo
{
    public class Sentence : LanguageComponentBase, IEnumerable<ILanguageComponent>
    {
        private readonly List<ILanguageComponent> _sentenceComponents;

        public Sentence(params ILanguageComponent[] sentenceComponents)
        {
            _sentenceComponents = new List<ILanguageComponent>(sentenceComponents);
        }

        public Sentence(IEnumerable<ILanguageComponent> sentenceComponents)
        {
            _sentenceComponents = new List<ILanguageComponent>(sentenceComponents);
        }

        public ILanguageComponent this[int index]
        {
            get { return _sentenceComponents[index]; }
        }

        public IEnumerator<ILanguageComponent> GetEnumerator()
        {
            return _sentenceComponents.GetEnumerator();
        }

        public override string Kana
        {
            get { throw new System.NotImplementedException(); }
        }

        public override string Romaji
        {
            get { throw new System.NotImplementedException(); }
        }

        public override string ToString()
        {
            StringBuilder sentence = new StringBuilder();

            foreach (ILanguageComponent sentenceComponent in _sentenceComponents)
            {
                sentence.Append(sentenceComponent);
            }

            return sentence.ToString();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public static Sentence Concat(Sentence sentence, ILanguageComponent c)
        {
            List<ILanguageComponent> concatonated = new List<ILanguageComponent>(sentence._sentenceComponents) { c };

            return new Sentence(concatonated);
        }
    }
}
